﻿<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" autoFlush="true"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/qa-category.tld" prefix="cat"%>
<%@ taglib uri="/WEB-INF/displaytag-el.tld" prefix="display" %>
<%@ taglib uri="/WEB-INF/qautil.tld" prefix="qautil"%>
<c:choose>
    <c:when test="${user_session.type == '1'}">
        <c:set value="true" var="adminRight"/>
    </c:when>
    <c:when test="${user_session.type != '1' and user_session.isSuper == true and fn:contains(user_session.permissions,questiono.mrIaskCategory.id)}">
        <c:set value="true" var="adminRight"/>
    </c:when>
    <c:when test="${user_session.userId == questiono.mrIaskUser.id}">
        <c:set value="true" var="authorRight"/>
    </c:when>
    <c:when test="${user_session.type != null}">
        <c:set value="true" var="logginedUserRight"/>
    </c:when>
</c:choose>
<c:out value="${adminRight}"/>-><c:out value="${authorRight}"/>-><c:out value="${logginedUserRight}"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/qa/js/catselect.js"></script>
<table width="720" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td width="600">
    <html:link page="/question.mrqa?action=list">帖子总汇</html:link><cat:catlinks objType="Q"/>
    </td>
    <logic:present name="user_session" scope="session">
    <td align="center" width="70">
        <c:if test="${user_session.type == '1'}">
            <c:if test="${questiono.state != '1' and questiono.state != '5'}">
            <html:link page="/question.mrqa?action=recommend" paramId="id" paramName="questiono" paramProperty="id">
                                <img src="qa/images/mr-qa-recommend-icon.gif" border="0" alt="推荐" align="bottom"/>推荐
            </html:link>
            </c:if>
        </c:if>
        <c:if test="${questiono.state == '1' or questiono.state == '5'}">
            <c:if test="${user_session.type == '1'}">
            <html:link page="/question.mrqa?action=unrecommend" paramId="id" paramName="questiono" paramProperty="id">
                                <img src="qa/images/mr-qa-recommend-icon.gif" border="0" alt="取消推荐" align="bottom"/>取消推荐
            </html:link>
            </c:if>
        </c:if>
    <td>
    <td align="center" width="60">
        <html:link page="/mylink.mrqa?action=add" paramId="questionId" paramName="questiono" paramProperty="id">
                    <img src="qa/images/mr-qa-mylink-icon.gif" border="0" alt="收藏" align="bottom"/>收藏
        </html:link>
    <td>
    </logic:present>
    <logic:notPresent name="user_session" scope="session">
        <c:if test="${questiono.state == '1' or questiono.state == '5'}">
            <td align="center" width="60">
                <!--推荐帖子-->
            <td>
        </c:if>
        <td align="center" width="60" title="请登陆后收藏">
                <img src="qa/images/mr-qa-mylink-icon.gif" border="0" alt="收藏" align="bottom"/>收藏
        <td>
    </logic:notPresent>
    <td align="right" valign="bottom" width="80"><img src="qa/images/mr-qa-question-icon.gif" border="0" alt="主题" align="bottom"/></td>
    </tr>
</table>
<!---===- -->
<div style="background-color:#FAFCFC;width:720;padding:4px 4px 4px 4px;border-left:1px solid #ccc;border-top:1px solid #ccc;border-right:1px solid #ccc;">
<table cellpadding="0" cellspacing="0" border="0" style="width:710;word-wrap:break-word;table-layout:fixed;">
    <tr>
        <td width="145" valign="top">
        <c:set var="user_id" value="${questiono.mrIaskUser.id}"/><html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id"><b><c:out value="${questiono.mrIaskUser.loginName}"/></b></html:link>
        <br>
        <c:out value="${questiono.mrIaskUser.userScore.title}"/>
        <br>
        <br>
        <fmt:formatDate value="${questiono.postDate}" var="postDate" type="both" pattern="yyyy-MM-dd HH:mm:ss"/>
        <c:out value="${postDate}"/>
        </td>
        <td valign="top">
            <div style="padding-bottom:10px;">
            <c:if test="${questiono.state != '2' and questiono.state != '5'}">
            <img src="qa/images/mr-qa-simplequestion-icon.gif" border="0" alt="普通帖子" align="bottom"/>
            </c:if>
            <c:if test="${questiono.state == '2' or questiono.state == '5'}">
            <img src="qa/images/mr-qa-complicated-question-icon.gif" border="0" alt="加急帖子" align="bottom"/>
            </c:if>
            <b><c:out value="${questiono.title}" escapeXml="false"/></b>
            </div>
            <pre><c:out escapeXml="false" value="${questiono.content}"/></pre>
            <logic:notEmpty property="reference" name="questiono">
                    <br><font color="#FFA500">参考:</font><a href="<bean:write property="reference" name="questiono"/>" target="_blank"><bean:write property="reference" name="questiono"/></a>
            </logic:notEmpty>
            <logic:notEmpty property="fileName" name="questiono">
                    <br><font color="#FFA500">附件:</font>
                    <a href="<%=com.mr.qa.GlobalConfigs.UPLOADEDFILE_DIR%><c:out value="${questiono.file}"/>">
                        <c:out value="${questiono.fileName}"/>
                    </a>
                    (请谨慎判断文件类型,避免恶意侵扰,网站不负责可能造成的损坏或损失)
            </logic:notEmpty>
            <logic:notEmpty property="addition" name="questiono">
                  <br>  
                  <font color="#FFA500">帖子补充：</font><br>  
                  <pre><c:out escapeXml="false" value="${questiono.addition}"/></pre>
             </logic:notEmpty>
                        <!--my supplement -->
                        <div id="questionsupplement" style="display:none">
                         <html:form action="/question" onsubmit="return supplementValidate(this);">
                            <html:hidden property="action" value="supplement"/>
                            <html:hidden property="id"/>
                            补充：<html:textarea property="addition" name="questiono" cols="60" rows="2"/><input type="submit" value="提交补充"/>
                         </html:form>
                         <script type="text/javascript">
                            function supplement(pLink)
                            {
                                var questionsupplementDiv = document.getElementById("questionsupplement");
                                if(questionsupplementDiv.style.display == "none")
                                    questionsupplementDiv.style.display = "block";
                                else
                                    questionsupplementDiv.style.display = "none";
                                return false;
                            }
                            function supplementValidate(pForm)
                            {
                                var addition = pForm.addition.value;
                                if(addition == "" || addition.length < 2)
                                {
                                    alert("[补充]必须填写，必须大于2个字符");
                                    return false;
                                }
                                return true;
                            }
                         </script>
                        </div>
          <!--comment -->
          <c:if test="${fn:length(questiono.mrIaskComments) > 0}">
          <br>
            <div>
                <span style="float:left;color:#FFA500;">对此帖子的评论:</span>
                <span style="float:right;cursor:hand;color:red" onclick="expandComments();" id="commentsDivOpenIndicator" title="关闭"><img id="commentImgSwitchor" src="qa/images/ico_collapse.gif"/></span>
            </div>
          <div id="commentsDiv">
            <br>          
            <c:forEach var="comment" items="${questiono.mrIaskComments}">
            <div style="padding-top:4px;">
                <pre><c:out value="${comment.content}" escapeXml="false"/></pre>
                <span style="float:left;">
                    <fmt:formatDate value="${comment.postDate}" var="postDate" type="both"/><c:out value="${postDate}"/>
                    <c:set var="comment_user_id" value="${comment.mrIaskUser.id}"/>
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="comment_user_id">
                    <c:out value="${comment.mrIaskUser.loginName}"/></html:link>
                </span>
                <span style="float:right;">
                    <c:if test="${user_session.userId == comment.mrIaskUser.id}">
                        <html:link page="/comment.mrqa?action=delete" paramId="id" paramName="comment" paramProperty="id" title="删除评论后不能恢复">
                            删除</html:link></c:if>
                    <c:if test="${user_session.userId != comment.mrIaskUser.id}">
                        <c:if test="${user_session.type == '1'}">
                        <html:link page="/comment.mrqa?action=delete" paramId="id" paramName="comment" paramProperty="id"  title="删除评论后不能恢复">
                            删除</html:link></c:if></c:if></span>
            </div>
            <hr>
            </c:forEach>
                <script type="text/javascript">
                    function expandComments()
                    {
                        var commentsDiv = document.getElementById("commentsDiv");
                        var commentsDivOpenIndicator = document.getElementById("commentsDivOpenIndicator");
                        var imgSwitchor = document.getElementById("commentImgSwitchor");
                        if(commentsDiv.style.display == "none")
                        {
                            commentsDiv.style.display = "block";
                            commentImgSwitchor.src = "qa/images/ico_collapse.gif";
                            commentsDivOpenIndicator.title = "关闭";
                        }
                        else
                        {
                            commentsDiv.style.display = "none";
                            commentImgSwitchor.src = "qa/images/ico_expand.gif";
                            commentsDivOpenIndicator.title = "展开";
                        }
                    }
                </script>
            </div>
            </c:if>
                        <!--comment form-->
                        <div id="commentdiv" style="display:none">
                         <html:form action="/comment" onsubmit="return commentValidate(this);">
                            <html:hidden property="action" value="add"/>
                            <html:hidden property="subjectType" value="Q"/>
                            <input type="hidden" name="subjectId" value="<c:out value="${questiono.id}"/>"/>
                            评论：<html:textarea property="content" cols="60" rows="2"/><input type="submit" value="提交评论"/>
                         </html:form>
                         <script type="text/javascript">
                            function icomment(pLink)
                            {
                                var commentDiv = document.getElementById("commentdiv");
                                if(commentDiv.style.display == "none")
                                    commentDiv.style.display = "block";
                                else
                                    commentDiv.style.display = "none";
                                return false;
                            }
                            function commentValidate(pForm)
                            {
                                var content = pForm.content.value;
                                if(content == "" || content.length < 2)
                                {
                                    alert("[评论]必须填写，必须大于2个字符");
                                    return false;
                                }
                                return true;
                            }
                         </script>
                        </div>    
        </td>
    </tr>
</table>
<!-- functions to question -->
<c:if test="${user_session != null}">
<script type="text/javascript">
    function ianswer()
    {
            var addAnswerDiv = document.getElementById("addAnswerDiv");        
            if(addAnswerDiv.style.display == "none")
                addAnswerDiv.style.display = "block";
            var modifyAnswerDiv = document.getElementById("modifyAnswerDiv");
            if(modifyAnswerDiv.style.display == "block")
                modifyAnswerDiv.style.display = "none";
            self.scrollTo(document.body.scrollWidth,document.body.scrollHeight);
            document.answer.content.focus();
    }
</script>
    <table width="710" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td width="215" align="right">
            <c:if test="${user_session != null}">
            <img src="qa/images/mr-qa-ianswer-button.gif" border="0" style="cursor:hand;" alt="我来回复" align="bottom" onclick="ianswer();"/>
            </c:if>
            </td>
            <td height="35" align="right">
                <c:if test="${user_session.userId == questiono.mrIaskUser.id}">
                    <c:if test="${user_session.type == '1'}">
                        <a href="#changecatanchor" onclick="changeQuestionCat();return false;" title="改变帖子分类">转移</a>
                        &nbsp;|&nbsp;
                    </c:if>
                    <c:if test="${questiono.state != '2' and questiono.state != '5'}">
                            <%request.setAttribute("curDate",new java.util.Date());%>
                            <c:set var="differ" value="${(curDate.time-questiono.postDate.time)/1000/60/60}"/>
                            <c:if test="${differ >= 24}">
                                <html:link page="/question.mrqa?action=complicate" paramId="id" paramName="questiono" paramProperty="id" title="此帖子超过24小时没有人回复,新帖子超过24小时没有回复可以设置为加急">
                                                加急
                                </html:link>
                                &nbsp;|&nbsp;
                            </c:if>
                    </c:if>
                    <c:if test="${questiono.state == '2' or questiono.state == '5'}">
                                <%request.setAttribute("curDate",new java.util.Date());%>
                                <c:set var="differ" value="${(curDate.time-questiono.postDate.time)/1000/60/60}"/>
                                <c:if test="${differ >= 24}">
                                    <html:link page="/question.mrqa?action=uncomplicate" paramId="id" paramName="questiono" paramProperty="id" title="此帖子超过24小时没有人回复,新帖子超过24小时没有回复可以设置为加急">
                                                    取消加急
                                    </html:link>
                                    &nbsp;|&nbsp;
                                </c:if>
                    </c:if>
                    <c:if test="${user_session.type == '1'}">
                            <logic:notEqual value="4" name="questiono" property="state">
                                <html:link page="/question.mrqa?action=close" paramId="id" paramName="questiono" paramProperty="id" title="隐藏此帖子,避免别的用户看到（仅作者能看到此连接）,你也可以在[用户中心]重新打开此帖子">
                                隐藏
                                </html:link>
                                &nbsp;|&nbsp;
                            </logic:notEqual>
                            <logic:equal value="4" name="questiono" property="state">
                                <html:link page="/question.mrqa?action=reopen" paramId="id" paramName="questiono" paramProperty="id" title="重开此帖子,使别的用户看到（仅作者能看到此连接）">
                                重开
                                </html:link>
                                &nbsp;|&nbsp;                            
                            </logic:equal>
                    </c:if>        
                    <html:link page="/question.mrqa?action=supplement" paramId="id" paramName="questiono" paramProperty="id" onclick="supplement(this);return false;" title="可以对你的帖子进行补充,以得到更好的答案（仅作者能看到此连接）">
                            补充
                    </html:link>
                    &nbsp;|&nbsp;
                    <a href="#modifyanchor" onclick="modifyQuestion();return false;" title=" 修改帖子">修改</a>
                    <!-- not over 24 hours-->
                    <c:if test="${user_session.type != '1'}">
                        <%request.setAttribute("curDate",new java.util.Date());%>
                        <c:set var="differ" value="${(curDate.time-questiono.postDate.time)/1000/60/60}"/>
                        <!--
                            在24小时内普通用户才能删除帖子
                        -->
                        <c:if test="${differ <= 24}">
                            &nbsp;|&nbsp;                
                            <html:link page="/question.mrqa?action=delete" paramId="id" paramName="questiono" paramProperty="id" title="发帖子24小时内普通用户可以删除帖子,帖子被删除后无法恢复">
                                删除
                            </html:link>
                        </c:if>
                    </c:if>
                    <c:if test="${user_session.type == '1'}">
                            &nbsp;|&nbsp;
                            <html:link page="/question.mrqa?action=delete" paramId="id" paramName="questiono" paramProperty="id" title="帖子被删除后无法恢复">
                                删除
                            </html:link>
                            &nbsp;|&nbsp;
                            <html:link page="/question.mrqa?action=top" paramId="id" paramName="questiono" paramProperty="id" title="置顶操作">
                                <c:if test="${questiono.isTop == false}">置顶</c:if>
                                <c:if test="${questiono.isTop == true}">取消置顶</c:if>
                            </html:link>
                            &nbsp;|&nbsp;
                            <html:link page="/question.mrqa?action=requirelogin" paramId="id" paramName="questiono" paramProperty="id" title="仅登录用户才能查看">
                                <c:if test="${questiono.isRequireLogin == false}">置登</c:if>
                                <c:if test="${questiono.isRequireLogin == true}">取消置登</c:if>
                            </html:link>
                    </c:if>
                </c:if>
                <c:if test="${user_session.userId != questiono.mrIaskUser.id}">
                    <c:if test="${user_session.type == '1'}">
                        <a href="#changecatanchor" onclick="changeQuestionCat();return false;" title="改变帖子分类">转移</a>
                        &nbsp;|&nbsp;
                        <c:if test="${questiono.state != '2' and questiono.state != '5'}">
                                <%request.setAttribute("curDate",new java.util.Date());%>
                                <c:set var="differ" value="${(curDate.time-questiono.postDate.time)/1000/60/60}"/>
                                <c:if test="${differ >= 24}">
                                    <html:link page="/question.mrqa?action=complicate" paramId="id" paramName="questiono" paramProperty="id" title="此帖子超过24小时没有人回复,新帖子超过24小时没有回复可以设置为加急">
                                                    加急
                                    </html:link>
                                    &nbsp;|&nbsp;
                                </c:if>
                        </c:if>
                        <c:if test="${questiono.state == '2' or questiono.state == '5'}">
                                <%request.setAttribute("curDate",new java.util.Date());%>
                                <c:set var="differ" value="${(curDate.time-questiono.postDate.time)/1000/60/60}"/>
                                <c:if test="${differ >= 24}">
                                    <html:link page="/question.mrqa?action=uncomplicate" paramId="id" paramName="questiono" paramProperty="id" title="此帖子超过24小时没有人回复,新帖子超过24小时没有回复可以设置为加急">
                                                    取消加急
                                    </html:link>
                                    &nbsp;|&nbsp;
                                </c:if>
                        </c:if>
                            <logic:notEqual value="4" name="questiono" property="state">
                                <html:link page="/question.mrqa?action=close" paramId="id" paramName="questiono" paramProperty="id" title="隐藏此帖子,避免别的用户看到（仅作者能看到此连接）,你也可以在[用户中心]重新打开此帖子">
                                隐藏
                                </html:link>
                                &nbsp;|&nbsp;
                            </logic:notEqual>
                            <logic:equal value="4" name="questiono" property="state">
                                <html:link page="/question.mrqa?action=reopen" paramId="id" paramName="questiono" paramProperty="id" title="重开此帖子,使别的用户看到（仅作者能看到此连接）">
                                重开
                                </html:link>
                                &nbsp;|&nbsp;                            
                            </logic:equal>
                            <html:link page="/question.mrqa?action=delete" paramId="id" paramName="questiono" paramProperty="id" title="帖子被删除后无法恢复">
                                删除
                            </html:link>
                            &nbsp;|&nbsp;
                            <a href="#modifyanchor" onclick="modifyQuestion();return false;" title=" 修改帖子">修改</a>                            
                            &nbsp;|&nbsp;
                            <html:link page="/question.mrqa?action=top" paramId="id" paramName="questiono" paramProperty="id" title="置顶操作">
                                <c:if test="${questiono.isTop == false}">置顶</c:if>
                                <c:if test="${questiono.isTop == true}">取消置顶</c:if>
                            </html:link>
                            &nbsp;|&nbsp;
                            <html:link page="/question.mrqa?action=requirelogin" paramId="id" paramName="questiono" paramProperty="id" title="仅登录用户才能查看">
                                <c:if test="${questiono.isRequireLogin == false}">置登</c:if>
                                <c:if test="${questiono.isRequireLogin == true}">取消置登</c:if>
                            </html:link>
                            &nbsp;|&nbsp;
                    </c:if>
                    <a href="#" onclick="icomment(this);return false;">评论</a>
                </c:if><br>
            </td>
        </tr>
    </table>
</c:if>
    <c:if test="${questiono.mrIaskUser.signature != ''}">
        <table width="710" cellpadding="0" cellspacing="0" border="0">
            <tr>
                    <td style="text-indent:144px;" align="left" height="26">
                    个人签名:&nbsp;&nbsp;<font color="blue"><c:out value="${questiono.mrIaskUser.signature}"/></font>
                    </td>
            </tr>
        </table>
    </c:if>
    <c:if test="${questiono.mrIaskCategory.isAds == true}">
        <table width="710" cellpadding="0" cellspacing="0" border="0">
            <html:form action="/cvup" enctype="multipart/form-data">
            <html:hidden property="questionId" value="${questiono.id}"/>
            <html:hidden property="questionCategoryId" value="${questiono.mrIaskCategory.name}"/>
            <tr>
                    <td style="text-indent:144px;" align="left" height="26">
                    简历:&nbsp;&nbsp;<html:file property="file" size="60"/>&nbsp;&nbsp;<html:submit value="立即发送"/>
                    </td>
            </tr>
            <tr>
                    <td style="text-indent:144px;" align="left" height="16">(支持.doc,.rtf,.pdf,.txt格式文件，文件必须小于3M)</td>
            </tr>
            </html:form>
        </table>
    </c:if>
</div>
<jsp:include page="anewslink.jsp"/>
<c:if test="${user_session.type == '1'}">
<!-- change question category form -->
<xml id="catsData">
      <cats id="cats">  
        <cat:insert type="D"/>
      </cats>
</xml>
<div id="changeQuestionCatDiv" style="display:none;">
<a name="changecatanchor"/>
<br>
<table class="mars" cellpadding="0" cellspacing="0">
    <html:form action="/question" method="post" onsubmit="return validateChangQuestionCatForm(this);">
    <html:hidden property="action" value="changecat"/>
    <input type="hidden" name="catId" value="<c:out value="${questiono.mrIaskCategory.id}"/>"/>
    <input type="hidden" name="id" value="<c:out value="${questiono.id}"/>"/>
    <tr class="even">
        <td colspan="2" align="left"><b>转移帖子</b></td>
    </tr>
    <tr>
        <td align="right">分类</td>
        <td valign="top">
            <html:select property="cat1Id" multiple="true" size="15" onchange="selectedCat1Changed(this)">
            </html:select>
            <html:select property="cat2Id" multiple="true" size="15" onchange="selectedCat2Changed(this)">
                <html:option value="">选择分类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html:option>
            </html:select>
            <html:select property="cat3Id" multiple="true" size="15">
                <html:option value="">选择分类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html:option>
            </html:select>*
        </td>
    </tr>
    <tr class="even">
        <td align="right"></td>
        <td>
            <input type="submit" value="保存修改"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="取消" onclick="changeQuestionCat();"/>
        </td>
    </tr>
    </html:form>
</table>
<script type="text/javascript">
    var questionfs = document.questionf;
    var actionCode;
    var questionForm;
    for(var i=0;i<questionfs.length;i++)
    {
        actionCode = questionfs[i].action.value;
        if(actionCode == "changecat")
        {
            questionForm = questionfs[i];
            break;
        }
    }
    try
    {
        if(questionForm != null)initSelect1(questionForm);
    }
    catch(err)
    {
        alert("初始化帖子分类出现异常："+err);
    }
    function changeQuestionCat()
    {
        var changeQuestionCatDiv = document.getElementById("changeQuestionCatDiv");
        if(changeQuestionCatDiv.style.display == "none")
        {
            changeQuestionCatDiv.style.display = "block";
            document.location.href = '#changecatanchor';
        }
        else
            changeQuestionCatDiv.style.display = "none";
        return false;
    }
    function validateChangQuestionCatForm(pForm)
    {
        var selectedCatIdValue = getSelectedCatIdValue(pForm);
        if(selectedCatIdValue == "")
        {
            alert("[分类]必须选择");
            return false;
        }
        pForm.catId.value = selectedCatIdValue;
        return true;    
    }
</script>
</div>
</c:if>
<c:if test="${user_session.userId == questiono.mrIaskUser.id or user_session.type == '1'}">
<a name="modifyanchor"/>
<div id="questionDiv" style="display:none;">
<br>
<table class="mars" cellpadding="0" cellspacing="0">
    <html:form action="/question" method="post" enctype="multipart/form-data" onsubmit="return validateq(this);">
    <html:hidden property="action" value="modify"/>
    <input type="hidden" name="catId" value="<c:out value="${questiono.mrIaskCategory.id}"/>"/>
    <input type="hidden" name="id" value="<c:out value="${questiono.id}"/>"/>
    <tr class="even">
        <td colspan="2" align="left"><b>修改帖子</b></td>
    </tr>
    <tr>
        <td align="right" width="148">标题</td>
        <td>
            <c:if test="${user_session.type == '1'}">
            <html:text property="title" name="questiono" size="60" maxlength="60"/>*(最长60个字符)
            </c:if>
            <c:if test="${user_session.type != '1'}">
            <html:text property="title" name="questiono" size="60" maxlength="40"/>*(最长40个字符)
            </c:if>
            <c:if test="${user_session.type == '1'}">
            &nbsp;&nbsp;<html:checkbox property="isRequireLogin"/>要求登录才能查看
            </c:if>
        </td>
    </tr> 
    <tr class="even">
        <td align="right">内容</td>
        <td>
            <textarea name="content" cols="77" rows="15"><c:out value="${questiono.content}" escapeXml="true"/></textarea>
        </td>
    </tr>
    <tr>
        <td align="right">补充</td>
        <td>
            <textarea name="addition" cols="77" rows="3"><c:out value="${questiono.addition}" escapeXml="true"/></textarea>
        </td>
    </tr>
    <tr class="even">
        <td align="right">参考</td>
        <td>
            <html:text property="reference" name="questiono" size="100" maxlength="100"/>
        </td>
    </tr>
   <tr class="even">
        <td align="right">附件</td>
        <td>
            <logic:notEmpty property="fileName" name="questiono">
                原附件:
                 <a href="<%=com.mr.qa.GlobalConfigs.UPLOADEDFILE_DIR%><c:out value="${questiono.file}"/>">
                        <c:out value="${questiono.fileName}"/>
                 </a>
                &nbsp;&nbsp;
                <html:link page="/question.mrqa?action=deletefile" paramId="id" paramName="questiono" paramProperty="id">
                        删除
                </html:link>
                <br>
            </logic:notEmpty>
            <html:file property="file" size="88"/>
            <br>(附件不能超过5M;如果重新上载，原文件被删除.)
        </td>
    </tr>
    <tr>
        <td align="right"></td>
        <td>
            <input type="submit" value="保存修改"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="取消" onclick="modifyQuestion();"/>
        </td>
    </tr>
    </html:form>
</table>
<script type="text/javascript">
    function validateq(pForm)
    {
        var title = pForm.title.value;
        if(title == "" || title.length < 1)
        {
            alert("[标题]必须填写，长度必须大于0");
            pForm.title.focus();
            return false;
        }
        var titleLengthValid = validateTitleLength(pForm.title.value,pForm.catId.value);
        if(!titleLengthValid)
        {
            alert("[标题]不能大于40个字符");
            pForm.title.focus();
            return false;
        }
        return true;
    }
    
    /*
    *validate the title length as per category id
    */
    function validateTitleLength(title,catId)
    {
        var specialCats = "48,49,51,16,18,19";
        if(title.length <= 40)
        {
            return true;
        }
        else if(specialCats.indexOf(catId) >= 0)
        {
            return true;
        }
        return false;
    }
    
    
    /**
    *dispaly or open the div for displaying the form of question for modifying
    */
    function modifyQuestion()
    {
        var questionDiv = document.getElementById("questionDiv");
        if(questionDiv.style.display == "none")
        {
            questionDiv.style.display = "block";
            var questionfs = document.questionf;
            var questionf;
            for(var i=0;i<questionfs.length;i++)
            {
                if(questionfs[i].action.value == "modify")
                {
                  questionf = questionfs[i];  
                  questionf.title.focus();
                  break;
                }
            }
            //self.scrollTo(document.body.scrollWidth,document.body.scrollHeight/2);
            document.location.href = "#modifyanchor";
        }
        else
            questionDiv.style.display = "none";
        return false;
    }
</script>
</div>
</c:if>
<!-- answers -->
<c:if test="${fn:length(questiono.mrIaskAnswers) > 0}">
<br>
<div style="margin-bottom:0;background:url(qa/images/mr-qa-answer-title.gif) no-repeat left"><span style="float:left;"><img src="qa/images/mr-qa-answer-title.gif" border="0" alt=""/></span>
<span style="float:right;cursor:hand;" onclick="expandAnswers();" id="answersDivOpenIndicator" title="关闭"><img id="imgSwitchor" src="qa/images/ico_collapse.gif"/><img src="qa/images/blank.gif" width="5" height="0"/></span></div>
<script type="text/javascript">
    function expandAnswers()
    {
        var answersDiv = document.getElementById("answersDiv");
        var answersDivOpenIndicator = document.getElementById("answersDivOpenIndicator");
        var imgSwitchor = document.getElementById("imgSwitchor");
        if(answersDiv.style.display == "none")
        {
            answersDiv.style.display = "block";
            imgSwitchor.src = "qa/images/ico_collapse.gif";
            answersDivOpenIndicator.title = "关闭";
        }
        else
        {
            answersDiv.style.display = "none";
            imgSwitchor.src = "qa/images/ico_expand.gif";
            answersDivOpenIndicator.title = "展开";
        }
    }
</script>
        <c:if test="${param.page == null}">
            <c:set var="page" value="1" scope="request"/>
        </c:if>
        <c:if test="${param.page != null}">
            <c:set var="page" value="${param.page}" scope="request"/>
        </c:if>
        <c:if test="${param.page == 0}">
            <c:set var="page" value="1" scope="request"/>
        </c:if>
        <c:if test="${param.pageSize == null}">
            <c:set var="pageSize" value="6" scope="request"/>
        </c:if>
        <c:if test="${param.pageSize != null}">
            <c:set var="pageSize" value="${param.pageSize}" scope="request"/>
        </c:if>
        <c:set var="resultSize" value="${fn:length(questiono.mrIaskAnswers)}" scope="request"/>
        <c:set var="begin" value="${(page-1)*pageSize}"/>
        <c:set var="end" value="${page*pageSize-1}"/>
        <div style="background-color:#FAFCFC;width:720;padding:4px 4px 4px 4px;border:1px solid #ccc;" id="answersDiv">
        <c:forEach var="answer" items="${questiono.mrIaskAnswers}" begin="${begin}" end="${end}">
        <table cellpadding="0" cellspacing="0" border="0" style="width:710;word-wrap:break-word;table-layout:fixed;">
       <tr>
            <td width="145" valign="top">
                <c:if test="${answer.mrIaskUser != null}">
                    <c:set var="user_id" value="${answer.mrIaskUser.id}"/>
                    <html:link page="/user.mrqa?action=viewuserbyother" styleId="author" paramId="id" paramName="user_id"><b><c:out value="${answer.mrIaskUser.loginName}"/></b></html:link>
                    <br>
                    <c:out value="${answer.mrIaskUser.userScore.title}"/>
                </c:if>
                <c:if test="${answer.mrIaskUser == null}">
                    IP:<c:out value="${answer.anonymousUser}"/>
                </c:if>
                <br>
                <br>
                <fmt:formatDate value="${answer.postDate}" var="postDate" type="both" pattern="yyyy-MM-dd HH:mm:ss"/>
                <c:out value="${postDate}"/>
            </td>
            <td valign="top">
                    <p>
                        <pre><c:out value="${answer.content}" escapeXml="fase"/></pre>
                    </p>
                    <p>                    
                    <c:if test="${fn:length(answer.reference) > 0}">
                        参考：<c:out value="${answer.reference}"/>&nbsp;&nbsp;&nbsp;
                    </c:if>
                    <c:if test="${fn:length(answer.file) > 0}">
                        附件：<c:out value="${answer.file}"/>
                    </c:if>                        
                    </p>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="right" style="border-bottom:1px dotted #ccc;">
            <div>
            <c:if test="${answer.mrIaskUser != null}">
                <span style="float:left;text-indent:144px;padding:3 0 3 0;">
                个人签名:&nbsp;&nbsp;<font color="blue"><c:out value="${answer.mrIaskUser.signature}"/></font>
                </span>
                <span style="float:right;padding:3 0 3 0;">
                <c:if test="${user_session.userId == answer.mrIaskUser.id}">
                        <html:link page="/answer.mrqa?action=premodify" paramId="id" paramName="answer" paramProperty="id" target="modifyAnswerFrame" onclick='modifyAnswer(this);'>修改</html:link>
                        &nbsp;|&nbsp;
                        <html:link page="/answer.mrqa?action=delete" paramId="id" paramName="answer" paramProperty="id">删除</html:link>
                </c:if>
                <c:if test="${user_session.userId != answer.mrIaskUser.id and user_session.type == '1'}">
                    <html:link page="/answer.mrqa?action=delete" paramId="id" paramName="answer" paramProperty="id">删除</html:link>
                </c:if>
                </span>
            </c:if>
            <c:if test="${answer.mrIaskUser == null and user_session.type == '1'}">
                <html:link page="/answer.mrqa?action=delete" paramId="id" paramName="answer" paramProperty="id">删除</html:link>
            </c:if>&nbsp;
            </div>
            </td>
        </tr>
        <tr>
        <td height="7"></td>
        </tr>
        </table>
       </c:forEach>
       <!--2--> 
</div>
</c:if>
<!-- pagination -->
<div><qautil:page action="/question.mrqa"/></div>
<div id="modifyAnswerDiv" style="display:none;">
    <br>
    <table border="0" cellpadding="0" cellspacing="0" align="center" width="720">
        <tr style="background:url(qa/images/dothline.gif) bottom;">
            <td width="720">
            &nbsp;&nbsp;&nbsp;&nbsp;<b>修改回复</b>
            </td>
        </tr>
    </table>
    <div style="width:720;padding:12px 0px 0px 4px;border-left:1px dotted #ccc;border-right:1px dotted #ccc;border-bottom:1px dotted #ccc;">
    <iframe src="about:blank" frameborder="0" scrolling="auto" name="modifyAnswerFrame" id="modifyAnswerFrame" width="100%" height="220"></iframe>
    </div>
    <input type="hidden" name="mafocus"/>
    <script type="text/javascript">
        function modifyAnswer(link)
        {
            var addAnswerDiv = document.getElementById("addAnswerDiv");        
            if(addAnswerDiv.style.display == "block" || addAnswerDiv.style.display == "")
                addAnswerDiv.style.display = "none";
            var modifyAnswerDiv = document.getElementById("modifyAnswerDiv");
            if(modifyAnswerDiv.style.display == "none")
                modifyAnswerDiv.style.display = "block";
            self.scrollTo(document.body.scrollWidth,document.body.scrollHeight);
        }
    </script>
</div>
<!-- add answer form -->
<c:if test="${questiono.state != '4'}">
<div id="addAnswerDiv">
<br>
<html:form action="/answer" enctype="multipart/form-data" focus="content" onsubmit="return validate(this);">
<html:hidden property="action" value="add"/>
<html:hidden property="page"/>
<html:hidden property="pageSize"/>
<input type="hidden" name="questionId" value="<bean:write name="questiono" property="id"/>"/>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="720">
    <tr style="background:url(qa/images/dothline.gif) bottom;">
        <td width="720">
        &nbsp;&nbsp;&nbsp;&nbsp;<b>我来回复</b>
        </td>
    </tr>
</table>
<div style="width:720;padding:12px 4px 4px 4px;border-left:1px dotted #ccc;border-right:1px dotted #ccc;border-bottom:1px dotted #ccc;">
<table align="center" width="100%" cellpadding="0" cellspacing="0">
   <tr>
        <td align="right" width="150">内容:<a name="answer">&nbsp;</a></td>
        <td>
            <html:textarea property="content" cols="77" rows="10"/>
        </td>
    </tr>
   <tr>
        <td align="right">参考:</td>
        <td>
            <html:text property="reference" value="http://" size="105"/>
        </td>
    </tr>
   <!-- 
   <tr>
        <td align="right">附件:</td>
        <td>
            <html:file property="file" size="50" disabled="true"/>
        </td>
    </tr>-->    
   <tr>
        <td align="right">&nbsp;</td>
        <td>
            <input type="submit" value="提交回复"/>
        </td>
    </tr>
    </html:form>
</table>
</div>
</div>
</c:if>
<input type="hidden" name="addAnswerFocus" id="addAnswerFocus"/>
<script type="text/javascript">
    function validate(pForm)
    {
        var content = pForm.content.value;
        if(content == "" || content.length < 1)
        {
            alert("[内容]必须填写，长度必须大于0");
            pForm.content.focus();
            return false;
        }
        return true;
    }
    function onVote(pSubmit)
    {
        pSubmit.form.action = "vote";
    }
    function onSetPollItems(pSubmit)
    {
        pSubmit.form.action = "setpollitems";
    }
</script>